import http from '@/utils/http/axios'
import { RequestEnum } from '@/enums/httpEnum'

export function fetchOrderPage(params) {
  return http.request(
    {
      url: '/order/page',
      method: RequestEnum.POST,
      params,
    },
  )
}

// 获取 model 的 type
export function fetchModelType() {
  return http.request(
    {
      url: '/model/types/get',
      method: RequestEnum.GET,
    },
  )
}

// 通过 type 获取 models
export function fetchModelsByType(params) {
  return http.request(
    {
      url: '/model/select',
      method: RequestEnum.GET,
      params,
    },
  )
}

// 通过 name 获取 公司
export function fetchCustomerByKeyWord(params) {
  return http.request(
    {
      url: '/company/list',
      method: RequestEnum.POST,
      params,
    },
  )
}

// 添加订单
export function addOrder(params, options?) {
  return http.request(
    {
      url: '/order/add',
      method: RequestEnum.POST,
      params,
    },
    options
  )
}

// 通过 id 获取 订单详情
export function getOrderDetailById(params) {
  return http.request(
    {
      url: `/order/detail`,
      method: RequestEnum.GET,
      params,
    },
  )
}

// 批量审核接口
export function batchAudit(params, options?) {
  return http.request(
    {
      url: `/order/check`,
      method: RequestEnum.POST,
      params,
    },
    options
  )
}

// 批量导出订单
export function exportOrderExcel(params) {
  return http.request(
    {
      url: `/order/download`,
      method: RequestEnum.POST,
      responseType: 'blob',
      params,
    },
  )
}
